﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //用户名，用户密码，确认密码
            var uid = textBox1.Text;
            var pwd = textBox2.Text;
            var rePwd = textBox3.Text;
            //防止空值
            var hasUid = !string.IsNullOrEmpty(uid);
            var hasPwd = !string.IsNullOrEmpty(pwd);
            //设置变量取值
            var eqPwd = pwd == rePwd;

            if (hasPwd && hasPwd && eqPwd)
            {
                var sql = string.Format("insert into Users (Username , Password) values ('{0}',{1})", uid, pwd);
                var td = DnHelper.GetDataTable(sql);
                MessageBox.Show("注册成功","提示");
                this.Close();
            }
            else
            {
                MessageBox.Show("注册失败","提示");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }
    }
}
